﻿using System;
using System.Collections.Generic;
using Infrastructure.Controls;
using Infrastructure.HardCoding;
using LinQProject;
using ServiceProject.EntityService;

public partial class controls_ucSearch : System.Web.UI.UserControl
{

    protected CategoryService categoryService = new CategoryService(database);
    //protected MaterialService materialService=new MaterialService(database);
    //protected ProductCategoryService productCategService=new ProductCategoryService(database);
    private static readonly FarmacieDataClassesDataContext database = new FarmacieDataClassesDataContext();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadControls();
        }
    }

    private void LoadControls()
    {
        //IList<ProductCategory> categList = productCategService.GetAll();
        //BindEntityToControls<ProductCategory>.BindEntityListToDDL(ddlCategory, categList, "ProductCategoryName", "ProductCategoryId", "Toate Categoriile");
        
        //IList<Material> materialList = materialService.GetMaterials(true);
        //BindEntityToControls<Material>.BindEntityListToDDL(ddlMaterial,materialList,"MaterialName","MaterialId","Toate Materialele");
      
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string responseRedirect =
            String.Format("MySearch.aspx?word={0}&categ={1}&material={2}&minPrice={3}&maxPrice={4}",
                txtSearch.Text,ddlCategory.SelectedValue,ddlMaterial.SelectedValue,txtminPrice.Text,txtmaxPrice.Text);
        Response.Redirect(responseRedirect);
    }
}
